<? header("Content-Type: text/html,charset=UTF-8"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  	<title>Result</title>
	<meta charset="utf-8">
	<link rel="shortcut icon" href="images/favicon.ico">
</head>

<body>

<?


$arr = array();


//Set data
for($i=0;$i<count($_POST["question"]);$i++){
	$arr[$i]["question"] = $_POST["question"][$i];

	$arr[$i]["question_type"] = $_POST["qType$i"];

	for($j=0;$j<count($_POST["answer$i"]);$j++){

		$arr[$i]["answer"][$j] = $_POST["answer$i"][$j];

	}
}

//echo "<br />";
//echo "Print Array :";
//echo "<br />";
//
print_r($arr);
//
//echo "<br />";
//echo "<br />";
//echo "<hr />";
//echo "<br />";
//echo "JSON Encode :";
//echo "<br />";
//
//echo $json = json_encode($arr);
//
//$obj = json_decode($json, true);
//
//echo "<br />";
//echo "<br />";
//echo "<hr />";
//echo "<br />";
//echo "JSON Decode :";
//echo "<br />";
//
//
//echo var_dump($obj);
//
//
//echo "<br />";
//echo "<br />";
//echo "<hr />";
//echo "<br />";
//echo "Get form JSON :";
//echo "<br />";
//echo "<br />";
//
//foreach($obj as $rs){
//	echo $rs["question"];
//	echo "<br />";
//	echo $rs["question_type"];
//	echo "<br />";
//	foreach($rs["answer"] as $a){
//		echo $a;
//		echo "<br />";
//	}
//	echo "<br />";
//}
//
//echo "<br />";
//echo "<br />";
//echo "<hr />";
//echo "<br />";
echo "Get form Array :";
echo "<br />";


//Print Data
foreach($arr as $key=>$data){echo "<br />";
	foreach($data as $label=>$value){
		if($label=="answer"){
			echo $label;
			echo "<br />";
			foreach($value as $val=>$a){
				echo $val." => ".$a;
				echo "<br />";
			}
		}else{
			echo $label." => ".$value;
			echo "<br />";
		}
	}
}



?>

</body>

</html>
